<template>
	<!-- 添加弹框 -->
		<el-dialog  width="55%" title=""   visible :show-close="false" :modal-append-to-body="false" class="wrap" @close="cancel" :close-on-click-modal="false">
		<i class="el-icon-close close" @click="cancel" style="color: white;"></i>
	    <div class="bt">添加学生资料</div>
		<el-form label-width="100px" :inline="true" class="form">
			<el-form-item label="学生名称" class="select-block">
				<el-input v-model="zwm" placeholder="请输入班级名称" icon="add"  ></el-input>
			</el-form-item>
			<el-form-item label="英文名称" class="select-block">
				<el-input v-model="ywm" placeholder="请输入班级名称" icon="add"  ></el-input>
			</el-form-item>
			<el-form-item label="学生性别" class="select-block">
				<el-select v-model="xb" style="width:92%"  placeholder="请选择性别" icon="add"  >
						<el-option label="男" value="男"></el-option>
						<el-option label="女" value="女" ></el-option>
				</el-select>
 			</el-form-item>
			<el-form-item label="介绍人" class="select-block">
				<el-input v-model="jshaor" placeholder="请输入班级名称" icon="add"  ></el-input>
			</el-form-item>
			<el-form-item label="父亲电话" class="select-block">
				<el-input v-model="fqdh" placeholder="请输入班级名称" icon="add"  ></el-input>
			</el-form-item>
			<el-form-item label="母亲电话" class="select-block">
				<el-input v-model="mqdh" placeholder="请输入班级名称" icon="add"  ></el-input>
			</el-form-item>
			<el-form-item label="微信" class="select-block">
				<el-input v-model="wx" placeholder="请输入班级名称" icon="add"  ></el-input>
			</el-form-item>
			<el-form-item label="联系电话" class="select-block">
				<el-input v-model="dh" placeholder="请输入班级名称" icon="add"  ></el-input>
			</el-form-item>
			<el-form-item label="年龄" class="select-block">
				<el-input v-model="age" placeholder="请输入班级名称" icon="add"  ></el-input>
			</el-form-item>
			<el-form-item label="招生来源" class="select-block">
				<el-input v-model="zsly" placeholder="请输入班级名称" icon="add"  ></el-input>
			</el-form-item>
			<el-form-item label="水平" class="select-block">
				<el-input v-model="sp" placeholder="请输入班级名称" icon="add"  ></el-input>
			</el-form-item>
			<el-form-item label="家庭住址" class="select-block">
				<el-input v-model="jtdz" placeholder="请输入班级名称" icon="add"  ></el-input>
			</el-form-item>
			<el-form-item label="公立学校" class="select-block">
				<el-input v-model="glxx" placeholder="请输入班级名称" icon="add"  ></el-input>
			</el-form-item>

			<el-form-item label="资源库" class="select-block">
				<el-input v-model="zyk" placeholder="请输入班级名称" icon="add"  ></el-input>
			</el-form-item>
			<el-form-item label="学生标签" class="select-block" style='width: 100%;'>
				<el-tag type="success" class="list1"   v-for="(v,index) in bqList">
					{{v}}
				<i class="el-icon-close del1" @click = "delbq(v)"></i>
				</el-tag>
							<el-button type="" size="small" @click="componentsShow('bq')">+标签</el-button>

			</el-form-item>
			<el-button type="primary" class="submit" @click="submit">保存</el-button>
			<BqComponent v-if="portComponents.bq.toggle" @close="componentsHide" :params="portComponents.bq.params"></BqComponent>
		</el-form>
		<!-- </el-dialog> -->
	</el-dialog>
</template>
<script type="text/javascript">
import BqComponent from '../../admin/xxjbszManage/bq'
	import qs from 'qs'
	export default {
		props: ['params'],
		components: {BqComponent },
		data() {
			return {
				bqList:[],
				zwm:'',
				ywm:'',
				xb:'',
				wx:'',
				dh:'',
				age:'',
				zsly:'',
				sp:'',
				jtdz:'',
				glxx:'',
				fqdh:'',
				mqdh:'',
				zyk:'',
				jshaor:'',
				portComponents: {
					bq: {
						type: 'bq',
						toggle: false,
						params: '',
						data: {}
					},
				}
			}
		},
		created() {
		},
		methods: {
			delbq(bq){
				var dd =[];
					for ( let i in this.bqList ) {
						if (this.bqList[i]==bq){
							continue}else{
							 dd.push(this.bqList[i]);
						}
					}
					this.bqList= dd;
			 },




			submit() {
				this.$store.state.loading = true;
				var logininfo = JSON.parse(localStorage.logininfo);
				var params3 = qs.stringify({
					zwm:this.zwm,
					ywm:this.ywm,
					xb:this.xb,
					wx:this.wx,
					dh:this.dh,
					age:this.age,
					zsly:this.zsly,
					sp:this.sp,
					jtdz:this.jtdz,
					glxx:this.glxx,
					fqdh:this.fqdh,
					mqdh:this.mqdh,
					jshaor:this.jshaor,
					zyk:this.zyk,
					xxid:logininfo.xxid,
					bq:this.bqList+'',
					yewuid:logininfo.id
				});
				//执行
				this.axios.post(this.$store.state.api + 'xsly/insert', params3)
					.then(res => {
						if(res.data.code == 1) {
							this.$emit('close', { type: 'listedit', cancel: false });
							this.$store.state.loading = false;
						} else {
							this.$emit('close', { type: 'listedit', cancel: false });
							this.$store.state.loading = false;
						}
					}).catch(res => {
						this.$message.warning("服务器繁忙，请重试");
						//this.$emit('close', { type: 'add', cancel: false });
						this.$store.state.loading = false;
					})
			},



			cancel() {
				this.$emit('close', { type: 'listedit', cancel: true })
			},
			componentsShow (type,data) { //显示组件
								console.log(type,data)
								for ( let i in this.portComponents ) {
										if (type == this.portComponents[i].type) {
												this.portComponents[i].toggle = true;
												this.portComponents[i].params = data;
												if (this.portComponents[i].data.type == 'single') {
														this.portComponents[i].data.index = data.row.id
												}else if(this.portComponents[i].data.type == 'multiple'){
														this.portComponents[i].data.index = this.multipleDelNum;
												}else{
														return;
												}
												return;
										}
								}
						},
						componentsHide (setting) { //关闭组件
								for ( let i in this.portComponents ) {
										if (setting.type == this.portComponents[i].type) {
											 this.portComponents[i].toggle = false;
											 if (this.portComponents[i].type=='bq'){
													if (!setting.cancel) {
														 for ( let b in setting.clist ) {

													 this.bqList.push( setting.clist[b]);
													}

													}
											 }else{
												if (!setting.cancel) {
												}
											 }
											 return;
										}
								}
						}
		}
	}
</script>
<style lang="less" scoped >
	.wrap {
		.row{
			height:50px;
			line-height: 50px;
		}
		.bt{
			position: absolute;
			width: 100%;
			height: 50px;
			margin: 0 auto;
			top: 0;
			left: 0;
			// margin-top: -70px;
			background: #50BFFF;
			// margin-left: -20px;
			// margin-bottom: 20px;
			color:white;
			text-align:left;
			line-height: 50px;
			font-size: 17px;
			padding-left: 15px;
		}
		.close{
				z-index: 10;
				position: absolute;
		}
		.input-block {
			margin-bottom: 20px;
			text-align: center;
		}
		.input {
			width:280px;
			display: inline-block;
			margin-left: 10px;
		}
		.input1 {
			width: 210px;
			display: inline-block;
			margin-left: 10px;
		}
		.input-block span {
			display: inline-block;
			width: 70px;
			text-align: right;
		}
		.submit {
			width: 120px;
			display: block;
			// float: left;
			margin: 0 auto;
			margin-top: 20px;
		}
		.wpfl {
			// background: red;
			// position: absolute;
			// top: 20%;
			// left: -10%;
		}
		.lskb {
			width: 130%;
			background: #fff;
			position: absolute;
			top: 5px;
			left: -66px;
			z-index: 50;
		}
		.wpfl1 {
			width: 130%;
			background: #fff;
			position: absolute;
			top: 5px;
			left: -66px;
		}
		.form {
			text-align: left;
			margin-top: 20px;
			.select-block {
				width: 45%;
				// display: block;
			}
			.select-block1 {
				width: 68%;
				// display: block;
			}
			.weekdiv{
				width: 100%;
				height: 100%;
				margin: 0 auto;
				background: lightblue;


			}
			.wdiv0 {
				line-height: 45px;
				width: 100px;
				height: 300px;
				float: left;
				background: lightgoldenrodyellow;
			}
			.wdiv1 {
				width: 40px;
				height: 300px;
				float: left;
				background: lightgoldenrodyellow;
			}
			.wdiv2 {
				width: 40px;
				height: 300px;
				float: left;
				background: lightgoldenrodyellow;
			}
			.wdiv3 {
				width: 40px;
				height: 300px;
				float: left;
				background: lightgoldenrodyellow;
			}
			.wdiv4 {
				width: 40px;
				height: 300px;
				float: left;
				background: lightgoldenrodyellow;
			}
			.wdiv5 {
				width: 40px;
				height: 300px;
				float: left;
				background: lightgoldenrodyellow;
			}
			.wdiv6 {
				width: 40px;
				height: 300px;
				float: left;
				background: lightgoldenrodyellow;
			}
			.wdiv7 {
				width: 40px;
				height: 300px;
				float: left;
				background: lightgoldenrodyellow;
			}
			.el-checkbox+.el-checkbox {
     margin-left: 0px;
}
		}


	}

</style>
